﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using NetFwTypeLib;
using Quartz;

namespace TimerJob.Task
{
    public class DisableFirewallJob : IJob
    {
        private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

        #region IJob Members

        public void Execute(IJobExecutionContext context)
        {
            Logger.Trace("Job {0} has been fired by schedule", context.JobDetail.Description);

            //FirewallManager.FirewallManager.IsRuleExists("notepad.exe");
            FirewallManager.FirewallManager.AddRule("notepad2", @"C:\Windows\Notepad.exe", true, true, false);
            FirewallManager.FirewallManager.AddRule("notepad2", @"C:\Windows\Notepad.exe", true, true, false);
            FirewallManager.FirewallManager.RemoveRule(@"C:\Windows\Notepad.exe", true);
            //FirewallManager.FirewallManager.RemoveApplicationAuth(@"C:\Windows\Notepad.exe");
            //bool result = FirewallManager.FirewallManager.AuthorizeApplication("Notepad", @"C:\Windows\Notepad.exe", NET_FW_SCOPE_.NET_FW_SCOPE_ALL, NET_FW_IP_VERSION_.NET_FW_IP_VERSION_ANY, false);
            //FirewallManager.FirewallManager.RemoveApplicationAuth(@"C:\Windows\Notepad.exe");

        }

        #endregion
    }

}
